//
//  MZYsecondTableViewCell.m
//  WristWatch
//
//  Created by dllo on 15/10/27.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "MZYsecondTableViewCell.h"
#define WIDTH self.contentView.frame.size.width
#define HEIGHT self.contentView.frame.size.height

@implementation MZYsecondTableViewCell


- (void)dealloc {
    [_nameLabel release];
    [_nameImageView release];
    [_priceLabel release];
    
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    return self;
}

- (void)createView {
    self.nameImageView = [[UIImageView alloc] init];
//        self.nameImageView.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:self.nameImageView];
    [_nameImageView release];
    
    self.nameLabel = [[UILabel alloc] init];
    [self.contentView addSubview:self.nameLabel];
    self.nameLabel.numberOfLines = 0;
//        self.nameLabel.backgroundColor = [UIColor yellowColor];
    [_nameLabel release];
    
    self.priceLabel = [[UILabel alloc] init];
    [self.contentView addSubview:self.priceLabel];
//    self.priceLabel.backgroundColor = [UIColor yellowColor];
    [_priceLabel release];
    
}


- (void)layoutSubviews {
    [super layoutSubviews];
    
    NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:18], NSFontAttributeName, nil];
    CGRect rect = [self.nameLabel.text boundingRectWithSize:CGSizeMake(WIDTH / 4 * 3, 0) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    self.nameLabel.frame = CGRectMake(WIDTH / 4, 10, WIDTH / 4 * 3, rect.size.height);
    //    self.nameLabel.frame = CGRectMake(WIDTH / 4, 0, WIDTH / 4 * 3, HEIGHT / 2);
    self.nameImageView.frame = CGRectMake(0, 10, WIDTH / 4, HEIGHT - 20);
    self.priceLabel.frame = CGRectMake(WIDTH/ 4, rect.size.height + 20, WIDTH / 4 * 3, HEIGHT / 3);
    
}





- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
